## 3.2.5 Flywheel Bike --------------- ### 3.2.5.1 Overview ![Img](./media/top1.png) Here we build a flywheel bike with a Micro:bit V2 board, a servo expansion board, two 360° LEGO servos and some LEGO parts. We program to control it to move through the Micro:bit V2 buttons A and B. ![Img](./media/bottom1.png) --------------- ### 3.2.5.2 Materials Required ![Img](./media/A5-0.png) --------------- ### 3.2.5.3 Installation Steps ![Img](./media/2top.png) ![Img](./media/A5-1.png) ![Img](./media/A5-2.png) ![Img](./media/A5-3.png) ![Img](./media/A5-4.png) ![Img](./media/A5-5.png) ![Img](./media/A5-6.png) ![Img](./media/A5-7.png) ![Img](./media/A5-8.png) ![Img](./media/A5-9.png) ![Img](./media/A5-10.png) ![Img](./media/A5-11.png) ![Img](./media/A5-12.png) ![Img](./media/A5-13.png) ![Img](./media/A5-14.png) ![Img](./media/A5-15.png) ![Img](./media/A5-16.png) ![Img](./media/A5-17.png) ![Img](./media/A5-18.png) ![Img](./media/A5-19.png) ![Img](./media/A5-20.png) ![Img](./media/A5-21.png) ![Img](./media/A5-22.png) ![Img](./media/A5-23.png) ![Img](./media/A5-24.png) ![Img](./media/A5-25.png) ![Img](./media/A5-26.png) ![Img](./media/A5-27.png) ![Img](./media/A5-28.png) ![Img](./media/A5-29.png) ![Img](./media/A5-30.png) ![Img](./media/A5-31.png) ![Img](./media/A5-32.png) ![Img](./media/A5-33.png) ![Img](./media/A5-34.png) ![Img](./media/A05.png) ![Img](./media/wiring5.png) ![Img](./media/A5-35.png) ![Img](./media/A5-36.png) ![Img](./media/A5-37.png) ![Img](./media/A5-38.png) ![Img](./media/A5-39.png) ![Img](./media/A5-40.png) ![Img](./media/A5-41.png) ![Img](./media/2bottom.png) --------------- ### 3.2.5.4 Test Code The speed values of 40 and 100 in the code can be adjusted according to your needs. ![Img](./media/couj05.png) ⚠️ **Special reminder: You can obtain the sample code through the following two methods.** #### **Method 1: drag and drop code blocks to build the sample code** **1. MakeCode programming environment** The online version of MakeCode: [MakeCode editor](https://makecode.microbit.org/#editor) **2. Makecode extension library** ⚠️ **Special reminder: ** Copy and paste the link: `https://github.com/keyestudio2019/pxt-creative-inventors-kit-master.git` into the search box to import the library. ![Img](./media/Animation-4.gif) **3. Write the sample code** ![Img](./media/dongtu-05.gif) #### **Method 2: download the sample code file directly** **1. Download the code file** Click to download the code file: [3_3_5_Flywheel_Bike](./Codes/3_3_5_Flywheel_Bike.hex) **2. MakeCode programming environment** The online version of MakeCode: [MakeCode editor](https://makecode.microbit.org/#editor) **3. Load the sample code** Drag and drop the sample code to the MakeCode editor. ![Img](./media/Animation-0001.gif) ![Img](./media/line1.png) --------------- ### 3.2.5.5 Test Result ![Img](./media/4top.png) Wire up and power on through Micro USB cable, and connect an external power source (four AAA-1.5V batteries installed in the battery box, ensuring sufficient power). To download the sample code using an online browser, you need to send the downloaded "**.hex**" file to the Micro:bit V2 board. There are two ways as follows: **① Download through WebUSB** For browsers like **Google Chrome / Microsoft Edge**, you need to click "**Connect Device**" to pair the device first. After that, click "**Download**" to load the sample code to the Micro:bit V2 board. ![Img](./media/Animation-05.gif) **② Download without WebUSB** For browsers like **Safari / Firefox / Other**, download and send the sample code to the Micro:bit V2 board. ![Img](./media/Animation-005.gif) After downloading the sample code, unplug the Micro USB cable to the Micro:bit V2 board. Turn the DIP switched to the RGB and ON. ![Img](./media/CBA01.png) Press button A on the Micro:bit V2 board and release it, the flywheel bike moves with its flywheel spinning, these SK6812 RGB LEDs emit colorful light and the 5×5 LED matrix displays ![Img](./media/ab3.png). Press button B on the Micro:bit V2 board and release it, the flywheel bike and its flywheel stop, and these SK6812 RGB LEDs and the 5×5 LED matrix turn off. ![Img](./media/dongtu-005.gif) ![Img](./media/4bottom.png) ---------------